package org.xm.sk.dao;

import java.util.List;
import java.util.Set;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.querydsl.QuerydslPredicateExecutor;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import org.xm.sk.vo.tb.Price;

@Repository
public interface PriceRepository extends JpaRepository<Price, Integer>,
        JpaSpecificationExecutor<Price>, QuerydslPredicateExecutor<Price> {

    Set<Price> findByName(String name);

    @Modifying
    @Query("UPDATE FROM Price u SET u.datalevel = 2, u.editer = :userid, u.editerName = :username WHERE u.id = :id")
    void delete(@Param("id") int id, @Param("userid") int userid,
            @Param("username") String username);

    @Modifying
    @Query("UPDATE FROM Price u SET u.datalevel = 2, u.editer = :userid, u.editerName = :username WHERE u.id in :ids")
    void delete(@Param("ids") Set<Integer> ids, @Param("userid") int userid,
            @Param("username") String username);

    List<Price> listByItemHairdress(List<Integer> itemIds, Integer hairdressId);

    Page<Price> listByItemHairdress(Pageable arg0, List<Integer> itemIds,
            Integer hairdressId);

    List<Price> list4Hairdress(Integer hairdressId);

    Page<Price> list4Hairdress(Pageable arg0, Integer hairdressId);

}
